Fix path traversal in zip extraction - #586
Merged
nikita-khapre merged 1 commit intoJun 29, 2026
Merged
Conversation
NaimShaqqou
approved these changes
Jun 25, 2026
ibrhmch
approved these changes
Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Currently,
unzip_folder()inebcli/core/fileoperations.pyextracts zip entries without validating that resolved file paths remain within the target directory. A zip entry named../../../.bashrc, for example, resolves outside the extraction directory and writes to an arbitrary location on the user's filesystem.A second vulnerable path exists in
createops.py, wheredownload_and_extract_sample_app()callsZipFile.extractall()with no filtering duringeb create.Fix
Before writing each file, resolve the target path with
os.path.realpath()and verify it starts with the extraction directory. If a zip entry would escape, raiseValidationErrorand refuse to write. Replace the bareextractall()increateops.pywith a call to the now-safeunzip_folder(), consolidating all extraction through the validated path.Testing
../traversal blocked, absolute paths blocked, deep/redundant legitimate paths work../../../../../../../tmp/eb-triage-pwned.txtentry --> unpatched code writes to/tmp/eb-triage-pwned.txt, patched code raisesValidationErrorand no file is written